<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>YK Value-added System</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/admin.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/common.css" />
	<script src="<%=basePath%>js/sys/validate.js" type="text/javascript"></script>
	<script src="<%=basePath%>js/json.js" type="text/javascript"></script>
	<script src="<%=basePath%>js/prototype.js" type="text/javascript"></script>
	<script type="text/javascript" charset="utf-8" defer="defer" src="<%=basePath%>js/wdatepicker/WdatePicker.js"></script>
	<script type="text/javascript">
		var judgment;
		function check(){
			value='';
			for(var i=0;i<document.getElementById("user").options.length;i++){
				if(value!=''){
					value=value+"`"+document.getElementById("user").options[i].value;
				}else{
					value=document.getElementById("user").options[i].value;
				}
			}
			document.getElementById("itemsVal").value=value;
		}

		function addUser(){//添加用户
			var obj2=document.getElementById("user2").options;//左
			var obj=document.getElementById("user").options;//右
			
			var w=true;
			var value="";
			for(var i=0;i<obj.length;i++){
				if(document.getElementById("user").options[i].value==document.getElementById("user2").options[obj2.selectedIndex].value){
					w=false;
				}
			}
			if(w){
				var aboj=new Option(document.getElementById("user2").options[obj2.selectedIndex].text,document.getElementById("user2").options[obj2.selectedIndex].value);
				document.getElementById("user").options.add(aboj);
			}
		}
		
		function deleteUser(){//删除用户
			if(document.getElementById("user").options.selectedIndex=="-1"){
				alert("请选中右选框中的用户信息！");
				return;
			}
			document.getElementById("user").removeChild(document.getElementById("user").options[document.getElementById("user").options.selectedIndex]);
		}
	</script>
  </head>
  
  <body>
<table width="95%" border="0" align="center" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0">
      <tr>
          <td colspan="2"><hr width="36%" align="left"></td>
		</tr>
    </table></td>
  </tr>
  <tr>
    <td><form id="form1" name="form1" method="post" action="<%=basePath%>admin/system/rightsMgmt/role!editRoleUser.action" onsubmit="return check();">
      <table width="40%" border="0" cellspacing="3">
      <tr>
          <td><font color="red" style="font-size:12px;"></font></td>
         <td>
          <font color="red" style="font-size:12px;"><s:actionmessage/><s:actionerror/></font>
          </td>
		</tr>
		<tr>
          <td>
          	用户列表：
          </td>
          <td align="left">
          	已选用户：
          </td>
        </tr>
        <tr>
        	<td>
	          	<select name="user2" id="user2" style="width: 180px;height:100px" multiple="multiple" ondblclick="addUser()">
	          		<s:iterator value="userList" id="user1">
	          			<option value="${user1.id}">${user1.username}</option>
	          		</s:iterator>
				</select>
	          </td>
	          <td align="left">
	          	<select name="user" id="user" style="width: 180px;height:100px" multiple="multiple" ondblclick="deleteUser()">
					<s:iterator value="roleUserList" id="user2">
	          			<option value="${user2.id}">${user2.username}</option>
	          		</s:iterator>
				</select>
				<input type="hidden" id="itemsVal" name="itemsVal" value="${itemsVal}"/>
				<input type="hidden" id="id" name="id" value="${role.id}"/>
	          </td>
        </tr>
		<tr>
          <td colspan="4"><hr width="92%" align="left"></td>
		</tr>
        <tr>
          <td align="right"><input type="submit" name="Submit" value="修改" class="Button" /></td>
          <td><input type="button" name="Submit22" value="返回" class="Button"  onclick="history.back();"/></td>
        </tr>
      </table>
        </form>
    </td>
  </tr>
</table>
</body>
</html>